<%@ page contentType="text/html; charset=utf-8" %>
<%@ include file="/WEB-INF/jsp/includeTaglib.jsp" %>
<tr>
  <td>
    <table width="100%" border="0" cellpadding="0" cellspacing="5">
      <tr>
        <td>
          <table width="100%" border="0" cellpadding="0" cellspacing="0">
            <tr>
              <td class="dashLeft"><img src="<c:url value='/images/spacer.gif' />" width="7" height="7"></td>
              <td align="center">
                <form:form commandName="sellingUploadSearchForm">
                <table width="100%" border="0" cellpadding="0" cellspacing="3">
                  <tr>
                    <td width="5%" height="20" class="globalText" nowrap="nowrap">项目编号</td>
                    <td width="20%" height="20" class="globalText">
                    	<input type="text" class="txtbox" size="20" name="projectCode" value="" />
                    </td>
                    <td width="5%" height="20" class="globalText" nowrap="nowrap">项目名称</td>
                    <td width="20%" height="20" class="globalText">
                      <input type="text" class="txtbox" size="20" name="projectName" value="" />
                    </td>
                    <td width="5%" height="20" class="globalText" nowrap="nowrap">终端编号</td>
                    <td width="20%" height="20" class="globalText">
                    	<input type="text" class="txtbox" size="20" name="channelCode" value="" />
                    </td>
                    <td width="5%" height="20" class="globalText" nowrap="nowrap">终端名称</td>
                    <td width="20%" height="20" class="globalText">
                    	<input type="text" class="txtbox" size="20" name="channelName" value="" />
                    </td>
                  </tr>
                  <tr>
                    <td width="5%" height="20" class="globalText" nowrap="nowrap">通路类别</td>
                    <td width="20%" height="20" class="globalText">
                      <select name="channelType">
                        <option value="">--全部--</option>
                        <c:forEach var="v" items="${channelTypeList}">
                          <option value="${v.id}">${v.name}</option>
                        </c:forEach>
                      </select>
                    </td>
                    <td width="5%" height="20" class="globalText" nowrap="nowrap">通路系统</td>
                    <td width="20%" height="20" class="globalText">
                      <select name="channelSystem">
                        <option value="">--全部--</option>
                          <c:forEach var="v" items="${channelSystemList}">
                            <option value="${v.code}">${v.name}</option>
                          </c:forEach>
                      </select>
                    </td>
                    <td width="5%" height="20" class="globalText" nowrap="nowrap">行政区划</td>
                    <td colspan="3" width="40%" nowrap>
                      <select id="provinceSelList" onchange="findDivision('1',this.options[this.selectedIndex].value,this.options[this.selectedIndex].text)" >
                        <option value="">--全部--</option>
                        <c:forEach var="ad" items="${provinceList}" >
                          <option value="${ad.code}">${ad.name}</option>
                        </c:forEach>
                      </select>
                      <select id="citySelList" onchange="findDivision('2',this.options[this.selectedIndex].value,this.options[this.selectedIndex].text)">
                        <option value="">--全部--</option>
                      </select>
                      <select id="disSelList">
                        <option value="">--全部--</option>
                      </select>
                      <input type="hidden" name="adCode" id="adCode" value="" />
                    </td>
                  </tr>
                  <tr>
                    <td width="5%" height="20" class="globalText" nowrap="nowrap">销量日期</td>
                    <td width="20%" height="20" class="globalText" colspan="2">
                        <input onclick="WdatePicker({dateFmt:'yyyy-M-d'});" type="text" class="txtbox" size="10" name="dateFrom" value="" />
                        ~
                        <input onclick="WdatePicker({dateFmt:'yyyy-M-d'});" type="text" class="txtbox" size="10" name="dateTo" value="" />
                    </td>
                  </tr>
                  <tr>
                    <td align="left" colspan="2"><input type="button" id="searchBtn" class="btnStyle" value="查询" onclick="doSearch()"></td>
                  </tr>
                </table>
                </form:form>
              </td>
            </tr>
          </table>
        </td>
      </tr>
    </table>
  </td>
</tr>
<script type="text/javascript">
  function findDivision(depth, code, adname){
    $.ajax({
      type: 'POST',
      url: '<c:url value="/json/findAdminDivisions.html" />',
      data: 'adname=' + encodeURIComponent(adname) + '&depth=' + depth + '&code=' + code,
      dataType: 'json',
      success: function(msg){
        var sel;
        if (depth == 1) {
          sel = $('#citySelList');
          $('#citySelList').empty();
          $('#disSelList').empty();
          $('#citySelList').append('<option value="">--全部--</option>');
          $('#disSelList').append('<option value="">--全部--</option>');
        } else if (depth == 2) {
          sel = $('#disSelList');
          $('#disSelList').empty();
          $('#disSelList').append('<option value="">--全部--</option>');
        }
        sel.empty();
        sel.append('<option value="">--全部--</option>');
        msg.forEach(function(val) {
          sel.append('<option value="' + val.id + '">' + val.name + '</option>');
        });
      }
    });
  }

  function doSearch() {
    var adCode = $('#disSelList').val() || $('#citySelList').val() || $('#provinceSelList').val() || '';
    $('#adCode').val(adCode.replace(/(00)+$/, ''));
    listDefaultPageAjax('sellingUploadListData','sellingUploadSearchForm','<c:url value="/report/sellingUpload/sellingUploadListData.html" />');
  }
</script>
